<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <div id="app">
    <parent>
      
    </parent>
   
    </div>
    <template id="comp1">
        <div>
<span>父组件</span>
<input type="text" v-model="mytitle" />
        </br>
<child :title="mytitle" @pchange="parentChange"></child></div>
    </template>
    <template id="comp2">
        <div>
        <input type="text" v-model="title" @change="doChildChange"/>
        <span> {{title}} 子组件   </span>
    </div>
    </template>
    <script src="js/vue.min.js"></script>
    <script>
    var vm=new Vue({
  el:"#app",
  components:{
      "parent":{
          template:"#comp1",
          data:function(){
             return {mytitle:'你好'}

          },
          methods:{
parentChange:function(val){
console.log(1234);
    this.mytitle=val;
}
          },
          components:{
              
            "child":{
                props:["title"],
              template:"#comp2",
              methods:{
                  doChildChange:function(){
               console.log(this.title);
                    this.$emit("pchange",this.title)
                  }
              }
            }
          }
      }
     
      
  }


    })
    
    
    </script>
</body>
</html>